package com.asset.common.exception;


import com.asset.common.enums.SystemEnum;

/**
 * @author luoyongzhi
 */
public class SysException extends RuntimeException implements IMessageCode {

    private static final long serialVersionUID = 9034287682828354793L;

    private String errCode;

    public SysException(Throwable cause) {
        super(cause);
        this.errCode = SystemEnum.UNKNOWN.code();
    }

    public SysException(SystemEnum systemEnum) {
        super(systemEnum.message());
        this.errCode = systemEnum.code();
    }

    public SysException(SystemEnum systemEnum, Throwable cause) {
        super(systemEnum.message(), cause);
        this.errCode = systemEnum.code();
    }

    public SysException(String code, String message) {
        super(message);
        this.errCode = code;
    }

    public SysException(String code, String message, Throwable cause) {
        super(message, cause);
        this.errCode = code;
    }

    @Override
    public String code() {
        return errCode;
    }

    @Override
    public String message() {
        return getMessage();
    }

}

